-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Multicast] Add Multicast statistics API #3354
Conversation
e2b7ec3
to
2291d90
Compare
Codecov Report
@@ Coverage Diff @@
## main #3354 +/- ##
===========================================
- Coverage 63.38% 42.06% -21.33%
===========================================
Files 280 325 +45
Lines 39750 51694 +11944
===========================================
- Hits 25197 21745 -3452
- Misses 12593 28330 +15737
+ Partials 1960 1619 -341
Flags with carried forward coverage won't be shown. Click here to find out more.
|
149a55b
to
949db7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question: why adding MulticastGroupMember/MulticastGroupMemberList in both pkg/apis/stats/types.go and pkg/apis/stats/v1alpha1/types.go? I think adding in pkg/apis/stats/v1alpha1/types.go is enough.
pkg/apis/controlplane/types.go
Outdated
MulticastStats []MulticastStats | ||
} | ||
|
||
// MulticastStats contains the information for Multicast Groups that a pod has joined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/MulticastStats contains the information for Multicast Groups that a pod has joined/MulticastStats contains the multicast groups that a Pod has joined/s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
After reading the docs provided, I think we should have the internal structs changes( |
949db7e
to
abd415d
Compare
/test-multicast-e2e |
// MulticastGroupMember contains the mapping between Multicast Group and Pods. | ||
type MulticastGroupMember struct { | ||
metav1.TypeMeta | ||
metav1.ObjectMeta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use standard K8s API for this, what would be the name of the object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the the name of the object would be same as group IP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also think it is not necessary to have a single field for name also namespace.
Pod *PodReference `json:"pod,omitempty" protobuf:"bytes,1,opt,name=pod"` | ||
|
||
// List of multicast IPs that the pod has joined. | ||
GroupJoinedList []IPAddress `json:"groupJoinedList,omitempty" protobuf:"bytes,2,rep,name=groupJoinedList"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename it "GroupList"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. The whole struct has changed.
} | ||
|
||
// MulticastStats contains the multicast groups that a Pod has joined. | ||
type MulticastStats struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks this struc is only for the group list per Pod? But the public API is shown pod list per group in MulticastGroupMember. Why use a different orgnization here?
Do you plan to show the multicast traffic stats in this API on the scenario no ANP is applied to the Pod?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks this struc is only for the group list per Pod? But the public API is shown pod list per group in MulticastGroupMember. Why use a different orgnization here?
Updated. Please check #3354 (comment)
Do you plan to show the multicast traffic stats in this API on the scenario no ANP is applied to the Pod?
No sure I understand your question. the group pods relation will be affected by multicast np. If igmp is block by np, the pod is not considered joined to the group in the final antctl get multicaststats
representation. no ANP and ANP with allow action to the igmp are considered to be the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean do you want to show the packet number in the MulticastStats as you only list the Pod count of a Group in this struct? Or the the multicast packet numbers are only shown in the result of ANP stats? But if a Multicast group is not applied with any ANP, we can't get the traffic numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to check traffic statistics not covered by ANP, you can check the command antctl get multicaststats
running in antrea-agent, as described here #3294.
@@ -325,6 +325,16 @@ type NodeStatsSummary struct { | |||
AntreaClusterNetworkPolicies []NetworkPolicyStats `json:"antreaClusterNetworkPolicies,omitempty" protobuf:"bytes,3,rep,name=antreaClusterNetworkPolicies"` | |||
// The TrafficStats of Antrea NetworkPolicies collected from the Node. | |||
AntreaNetworkPolicies []NetworkPolicyStats `json:"antreaNetworkPolicies,omitempty" protobuf:"bytes,4,rep,name=antreaNetworkPolicies"` | |||
// List of PodMulticast statistics collected from the Node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Multicast stats API should start from version v1alpha1 if you don't change the feature gate version.
Besides, does this new kind need to add into the function addConversionFuncs
https://github.com/antrea-io/antrea/blob/main/pkg/apis/controlplane/v1beta2/conversion.go#L28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Multicast stats API should start from version v1alpha1 if you don't change the feature gate version.
I think the the API changed I made at controlplane in this pr fit the case described here Adding Unstable Features to Stable Versions https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md#adding-unstable-features-to-stable-versions
Besides, does this new kind need to add into the function addConversionFuncs https://github.com/antrea-io/antrea/blob/main/pkg/apis/controlplane/v1beta2/conversion.go#L28
I checked the auto-generated func Convert_v1beta2_MulticastStats_To_controlplane_MulticastStats
and Convert_controlplane_MulticastStats_To_v1beta2_MulticastStats
, both LGTM. Could you explain why we need add addConversionFuncs
? Actually addConversionFuncs
confuses me because delete the one kind from this func doesn't affect the generated code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tnqn Could you take a look at these questions? Not sure my description was correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could follow https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md#new-field-in-existing-api-version?
The field could be added to the struct, but whether it will be collected, filled, and consumed depends on whether MulticastStats
feature gate is enabled.
If we want to reuse the NodeStatsSummary
API to report multicast stats data, we cannot really have another version starting from v1alpha1.
8c3e41d
to
0ade78f
Compare
0ade78f
to
2414b35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall
@@ -342,6 +342,16 @@ type NodeStatsSummary struct { | |||
AntreaClusterNetworkPolicies []NetworkPolicyStats `json:"antreaClusterNetworkPolicies,omitempty" protobuf:"bytes,3,rep,name=antreaClusterNetworkPolicies"` | |||
// The TrafficStats of Antrea NetworkPolicies collected from the Node. | |||
AntreaNetworkPolicies []NetworkPolicyStats `json:"antreaNetworkPolicies,omitempty" protobuf:"bytes,4,rep,name=antreaNetworkPolicies"` | |||
// List of PodMulticast statistics collected from the Node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could we make the comment consistent with the one in pkg/apis/controlplane/types.go
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
pkg/apis/stats/v1alpha1/types.go
Outdated
@@ -85,6 +85,34 @@ type NetworkPolicyStats struct { | |||
TrafficStats TrafficStats `json:"trafficStats,omitempty" protobuf:"bytes,2,opt,name=trafficStats"` | |||
} | |||
|
|||
// +genclient | |||
// +resourceName=multicastgroupmembers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this is not required. It was added to xxxstats struct because its plural automatically generated is not correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
pkg/apis/stats/v1alpha1/types.go
Outdated
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// MulticastGroupMember contains the mapping between Multicast Group and Pods. | ||
type MulticastGroupMember struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we plan to have more information for MulticastGroup that can be exposed by this API?
If no, current API name and group work for me.
If yes, I wonder if we should just use single API for all information specific to MulticastGroup, name it MulticastGroup
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we don't have plan to expose more group-level multicast information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be called MulticastGroupMembers
, but I also feel a more generic name like MulticastGroup
or MulticastGroupInfo
is better for future extensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Changed struct name to MulticastGroup. Trade explicitness for extensibility seems to be a good deal for me.
2414b35
to
fadf317
Compare
Currently, my implementation is antrea-agents sending whole multicast stats to the controller, which aligns with the control plane API change in the pr.
pros and cons:
|
I prefer agent to send the full update ( containing all latest statistics ) every time. |
Incremental style may not just work: antrea-controller doesn't persist data, using incremental update will also introduce the problem when it's time to do a full sync (how does agent know antrea-controller restarts). A periodical sync of a list of Pods that have joined a group seems fine to me. There were only 110 Pods on a Node at most by K8s default configuration, even they are all for multicast, the data was just few KBs per group, considering each Pod object in K8s also has few KBs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall, it's a bit strange to me that we use the stats terminology and the existing stats API to report multicast group membership information
pkg/apis/controlplane/types.go
Outdated
|
||
// MulticastStats contains the multicast groups that a Pod has joined. | ||
type MulticastStats struct { | ||
// Group is the IP of Multicast Group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Group is the IP of Multicast Group. | |
// Group is the IP of the multicast group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
pkg/apis/controlplane/types.go
Outdated
type MulticastStats struct { | ||
// Group is the IP of Multicast Group. | ||
Group string | ||
// Pods is the list of Pods that has joined the multicast group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Pods is the list of Pods that has joined the multicast group. | |
// Pods is the list of Pods that have joined the multicast group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
pkg/apis/controlplane/types.go
Outdated
Multicast []MulticastStats | ||
} | ||
|
||
// MulticastStats contains the multicast groups that a Pod has joined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// MulticastStats contains the multicast groups that a Pod has joined. | |
// MulticastStats contains the list of Pods that has joined a multicast group, for a given Node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
pkg/apis/controlplane/types.go
Outdated
// The stats related to multicast collected from the Node. | ||
Multicast []MulticastStats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand it correctly, you were implying MulticastStats should not be put in NodeStatsSummary API because it doesn't include real stats(only group-pod membership) for now. It should be added to another controlplane API.
For me creating a new API may seem like overkill. Also, We may add extra stats-like fields in this struct in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Antonin means the struct should not be named as MulticastStats as it has nothing to do with stats. If there is no plan to add statistics to the struct in future, probably name it MulticastGroupInfo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using the same API (NodeStatsSummary
) is good, even though in a future version maybe the API should be renamed to something more generic (e.g., NodeSummary
). But yes, you don't have any stats in MulticastStats
at the moment, and MulticastGroupInfo
sounds like a more appropriate name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Thanks for the explanation.
403c2c6
to
1e0024f
Compare
pkg/apis/controlplane/types.go
Outdated
@@ -340,6 +340,16 @@ type NodeStatsSummary struct { | |||
AntreaClusterNetworkPolicies []NetworkPolicyStats | |||
// The TrafficStats of Antrea NetworkPolicies collected from the Node. | |||
AntreaNetworkPolicies []NetworkPolicyStats | |||
// The stats related to multicast collected from the Node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revise the comments too: The stats ... -> Multicast group information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Thanks
1e0024f
to
04b344c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits.
pkg/apis/controlplane/types.go
Outdated
@@ -340,6 +340,16 @@ type NodeStatsSummary struct { | |||
AntreaClusterNetworkPolicies []NetworkPolicyStats | |||
// The TrafficStats of Antrea NetworkPolicies collected from the Node. | |||
AntreaNetworkPolicies []NetworkPolicyStats | |||
// Multicast group information related to multicast collected from the Node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove "related to multicast"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Multicast []MulticastGroupInfo `json:"multicast,omitempty" protobuf:"bytes,5,rep,name=multicast"` | ||
} | ||
|
||
// MulticastGroupInfo contains the list of Pods that has joined a multicast group, for a given Node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has -> have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
pkg/apis/stats/v1alpha1/types.go
Outdated
// +genclient:nonNamespaced | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// MulticastGroup contains the mapping between Multicast Group and Pods. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel no need to capitalize "Multicast Group".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
04b344c
to
f75d166
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Others might have more comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as well
f75d166
to
ee0d87c
Compare
/test-all |
/test-e2e |
@ceclinux I just realized the commit message is out of date, please update the PR description with correct one, I will use it when merging the commit. |
This PR adds a field Multicast for control-plane API NodeStatsSummary and field MulticastGroup for public statistics API group. Signed-off-by: ceclinux <[email protected]>
ee0d87c
to
594715f
Compare
updated. |
/skip-all |
This PR adds a field Multicast for control-plane API NodeStatsSummary
and field MulticastGroup for public statistics API group.
Signed-off-by: ceclinux [email protected]
For #3294